package com.woniu.utils;

import java.util.Date;

/**
 * @author Ma.Lei
 * @description
 * @date 2022/12/23 17:44
 */
public class UserParkTimeUtils {

    public static String timeDiff(Date createTime,Date endTime) {
//        Date nowDate =  new Date();
//        System.out.println("驶入时间："+createTime);
//        System.out.println("当前时间："+nowDate);
        long day=(endTime.getTime()-createTime.getTime())/1000/60/60/24;//获取两个时间相差天数
        long hour=(endTime.getTime()-createTime.getTime())/1000/60/60%24;//获取两个时间相差的小时
        long minute=(endTime.getTime()-createTime.getTime())/1000/60%60;//获取两个时间相差的分钟
//        System.out.println("两个时间差为：" + day + "天" + hour + "小时" + minute + "分钟");
        if (day == 0){
            if (hour == 0){
                return   minute + "分钟" ;
            }
            return  hour + "小时" + minute + "分钟" ;
        }
        return day + "天" + hour + "小时" + minute + "分钟" ;
    }
}
